﻿using System;
using System.Collections.Generic;
using System.Text;
using OAuth;

namespace Tweets.Library
{
    /// <summary>
    /// Base class for Twitter authentication settings.
    /// </summary>
    public abstract class TwitterBase
    {
        /// <summary>
        /// OAuth configuration.
        /// </summary>
        private OAuthConfig _config;

        /// <summary>
        /// Constructor requiring OAuth configuration.
        /// </summary>
        /// <param name="config">OAuth configuration.</param>
        public TwitterBase(OAuthConfig config)
        {
            _config = config;
        }

        /// <summary>
        /// OAuth configuration.
        /// </summary>
        public OAuthConfig Configuration
        {
            get { return _config; }
        }

        /// <summary>
        /// Twitter date/time format.
        /// </summary>
        public static readonly string TwitterDateTimeFormat = "ddd MMM dd HH:mm:ss %zzzz yyyy";

        /// <summary>
        /// Helper method to parse Twitter-formatted date/time entities.
        /// </summary>
        /// <param name="date">String date/time from Twitter.</param>
        /// <returns></returns>
        public static DateTime ParseTwitterDate(string date)
        {
            DateTime theDate = DateTime.ParseExact(date, TwitterDateTimeFormat, null);
            return theDate;
        }
    }
}
